package com.jboltai.capability.message;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;

/**
 * ai消息
 */
public class AIMessage {

    private String id;

    /**
     * 角色
     */
    private AIMessageRole role;

    /**
     * 内容
     */
    private String content;

    /**
     * 大模型思考
     */
    private String think;


    /**
     * 图片地址
     */
    private String[] imgUrls;




    public AIMessage() {}

    public AIMessage(AIMessageRole role, String content) {
        this.role = role;
        this.content = content;
    }
    public AIMessage(AIMessageRole role, String content, String... imgUrls) {
        this.role = role;
        this.content = content;
        this.imgUrls = imgUrls;
    }

    public static AIMessage of(String content){
        return new AIMessage(AIMessageRole.user, content);
    }

    public static AIMessage of(String content,String... imgUrls){
        return new AIMessage(AIMessageRole.user, content,imgUrls);
    }

    public static AIMessage ofSystem(String content){
        return new AIMessage(AIMessageRole.system, content);
    }

    public static AIMessage ofAssistant(String content){
        return new AIMessage(AIMessageRole.assistant, content);
    }

    public AIMessageRole getRole() {
        return role;
    }

    public void setRole(AIMessageRole role) {
        this.role = role;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {

        this.content = content;
    }

    public String getThink() {
        return think;
    }

    public void setThink(String think) {
        this.think = think;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String[] getImgUrl() {
        return imgUrls;
    }

    public void setImgUrls(String[] imgUrls) {
        this.imgUrls = imgUrls;
    }

    @JSONField(serialize = false)
    public JSONObject toJSONObject(){
        JSONObject object = new JSONObject();
        object.put("role",this.role);
        object.put("content",this.content);
        object.put("think",this.think);
        return object;
    }

    @JSONField(serialize = false)
    public boolean isUserMessage() {
        return AIMessageRole.user == role;
    }
    @JSONField(serialize = false)
    public boolean isSystemMessage() {
        return AIMessageRole.system == role;
    }

    @JSONField(serialize = false)
    public boolean isAssistantMessage() {
        return AIMessageRole.assistant == role;
    }




}
